using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Utility;
using DTO;

namespace BUS
{
   public class tbdonhangBUS
    {
       public static tbdonhangcollection Get(string where,
          int pageindex,
          int pagesize,
          string orderby,
          string orderdirection,
          out int total)
        {
            tbdonhangDAL donhangDAL = new tbdonhangDAL();
            return donhangDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbdonhangcollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbdonhangDAL donhangDAL = new tbdonhangDAL();
            return donhangDAL.Get(cri.Criter, 0, 0, donhangcolumns.madonhang.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbdonhang GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, donhangcolumns.madonhang.ToString(), Condition.EQUAL, iD);
            tbdonhangDAL donhangDAL = new tbdonhangDAL();
            tbdonhangcollection donhangcollection = donhangDAL.Get(cri.Criter,
                     0, 0, donhangcolumns.madonhang.ToString(), OrderDirection.ASC.ToString(), out total);
            if (donhangcollection.Count > 0)
                return donhangcollection[0];
            return null;
        }
    }
}
